require(['./config'], () => {
    require(['jquery', 'aJax', 'swiper', 'swiper2'], ($, ajax, swiper, swiper2) => {
        $('.header-container').load('./html/header.html', function () {
            class Navtop {
                constructor() {
                    // 获取搜索框元素
                    this.search = document.querySelector('.search-input')
                    this.searchInfo = document.querySelector('.search-info')
                 
                  
                    this.init()
                }
                init() {
                    this.search_info()
                }
                // 搜索框信息
                search_info() {
                    this.search.onkeyup = () => {
                        this.searchInfo.style.display = 'block'
                        this.searchInfo.innerHTML = '';
                        let wd = this.search.value;
                        if (wd.trim().length == 0) {
                            this.searchInfo.innerHTML = '';
                            return;
                        }
                        let that = this;
                        // 获取数据
                        $.ajax({
                            url: 'https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su',
                            dataType: 'jsonp',
                            data: {
                                wd
                            },
                            success(res) {
                                that.searchInfo.innerHTML = '';
                                res.s.forEach((item) => {
                                    that.searchInfo.innerHTML += `  <li>${item}</li>`
                                });
                            },
                            jsonp: 'cb', // jsonp 请求的时候回调函数的 key
                            // jsonpCallback: 'fn'   // jsonp 请求的时候回调函数的名称
                        })
                    }
                    this.searchInfo.onclick = () => {
                        this.searchInfo.style.display = 'none'
                    }
                   
                }
            }
            new Navtop()
        })





        $('.footer-container').load('./html/footer.html')
        new swiper()
        new swiper2()
    })
})